//
// A Simple Game Engine
//
// Copyright 2009 CG & CAD Institute, Tsinghua University.
// All rights reserved.
//

#ifndef __ENGINE__SPRITE_APPEARED__
#define __ENGINE__SPRITE_APPEARED__

#include "SDL/SDL.h"
#include "SDL/SDL_image.h"
#include <string>

namespace engine
{

typedef int         BOUNDSACTION;
const BOUNDSACTION  BA_STOP   = 0,
                    BA_WRAP   = 1,
                    BA_BOUNCE = 2,
                    BA_DIE    = 3;

struct Point
{
    int x;
    int y;
};

/**
 * TODO:
 */
class Sprite
{
// public type forward-declarations & typedefs & defs
public:
    typedef unsigned char UNIT8;

// public constructors & destructor
public:
    /**
     * TODO:
     */
    Sprite(std::string fileName, BOUNDSACTION boundsAction = BA_STOP);
    Sprite(std::string fileName, UNIT8 r, UNIT8 g, UNIT8 b, BOUNDSACTION boundsAction = BA_STOP);
    ~Sprite(void);

// public member functions
public:
    void Update();
    void Draw(SDL_Surface* destination);
    bool IsPointInside(int x, int y);
    bool TestCollision(Sprite* testSprite);
    void SetPosition(int x, int y);
    Point GetPosition();
    void SetVelocity(int xVel, int yVel);
    Point GetVelocity();
    void SetBound(SDL_Rect bound);
    SDL_Rect GetBound();
    void SetCollision(SDL_Rect collision);
    SDL_Rect GetCollision();

// private member functions
private:
    void LoadImage(std::string fileName);

// private data members
private:
    SDL_Surface* _surface;
    Point _position;
    Point _velocity;
    SDL_Rect _bound;
    SDL_Rect _collision;
    BOUNDSACTION _boundsAction;

// private constructors & destructor
private:
    // Disable the evil constructor and assignment operator.
    Sprite(const Sprite&);
    Sprite& operator=(const Sprite&);
};

} // namespace engine

#endif // __ENGINE__SPRITE_APPEARED__
